package com.caszx.chargingpile.adapter;

import java.util.List;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.caszx.chargingpile.R;
import com.caszx.chargingpile.entity.EntityCity;
import com.eowise.recyclerview.stickyheaders.StickyHeadersAdapter;

/**
 * 地点优先列表的头部
 * 
 */
public class LocationHeadAdapter implements StickyHeadersAdapter<LocationHeadAdapter.ViewHolder> {

	private List<EntityCity> items;
	public LocationHeadAdapter(List<EntityCity> items) {
		this.items = items;
	}

	@Override
	public ViewHolder onCreateViewHolder(ViewGroup parent) {
		View itemView = LayoutInflater.from(parent.getContext()).inflate(
				R.layout.item_loaction_head, parent, false);
		return new ViewHolder(itemView);
	}

	@Override
	public void onBindViewHolder(ViewHolder headerViewHolder, int position) {
		if(position == 0){
			headerViewHolder.cityhead.setText("定位城市");
		}else{
			headerViewHolder.cityhead.setText("更多");
		}
	}

	public void setData(List<EntityCity> items) {
		this.items = items;
	}

	@Override
	public long getHeaderId(int position) {
		if(position == 0){
			return 0;
		}
		return 1;
	}

	static class ViewHolder extends RecyclerView.ViewHolder {
		TextView cityhead;
		public ViewHolder(View itemView) {
			super(itemView);
			cityhead = (TextView) itemView.findViewById(R.id.cityhead);
		}
	}
}
